const _function = require("../../utils/functionData.js")
Page({
  data: {
    planList: [
      // {
      //   id: 1,
      //   title: '完成JavaScript基础学习',
      //   progress: 60,
      //   detail: '计划在两周内完成JavaScript基础学习...'
      // },
    ],
    showPopup: false,
    formData: {
      title: '',
      type: getApp().globalData.userInfo.role,
      content: '',
      createBy: getApp().globalData.userInfo.userId,
    }
  },
  onLoad() {
    this.getplanList()
  },
  onShow() {
    this.getplanList()
  },
  viewPlanDetail: function (event) {
    console.log('event',event);
    const planId = event.currentTarget.dataset.id;
    wx.navigateTo({
      url: `/pages/planDetail/planDetail?id=${planId}`
    });
    // wx.navigateTo({
    //   url: `/pages/planDetail/planDetail?id=${planId}`
    // });
    // wx.navigateTo({
    //   url: `/pages/discussiondetail/discussiondetail?data=${encodeURIComponent(JSON.stringify(item))}`
    // });
  },
  // 下定计划
  addPlan: function () {
    wx.navigateTo({
      url: '/pages/planform/planform'
    });
  },
     // 获取学习计划列表
     getplanList() {
      // console.log('选择时间', getApp().globalData.userInfo);
      // const id = getApp().globalData.userInfo.userId
      _function.getplanList(this.data.playId, '', this.getplanListBack, this)
    },
    getplanListBack(res) {
      let dataAll = res.data
      if (dataAll.code == 200) {
        console.log('视频列表', dataAll);
        this.setData({
          planList: dataAll.rows
        })
        wx.showToast({
          title: dataAll.msg,
          icon: 'none', // 不显示图标
          duration: 1500, // 提示的延迟时间，单位毫秒，默认为 1500
          mask: true, // 是否显示透明蒙层，防止触摸穿透，默认为 `false`
          success: () => {
            // console.log('登录失败提示已显示');
          }
        });
      }
    },



});